package com.sinoyd.itszyw.Adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import com.sinoyd.itszyw.Fragment.MaintainTaskFragment;
import com.sinoyd.itszyw.Fragment.MoreFragment;
import com.sinoyd.itszyw.Fragment.RoutineInspectionFragment;

/**
 * @author: Sinoyd  --------->作者
 * @description: --------->描述
 * @projectName: ITSZYW  ---------> 项目名称
 * @date: 2017-03-10 ---------> 创建日期
 * @time: 09:34       ---------> 创建时间
 */
public class MyFragmentManagerPageAdatper extends FragmentPagerAdapter {

    private MaintainTaskFragment mTaskFragment = null;
    private RoutineInspectionFragment  mInspectionFragment = null;
    private MoreFragment mMoreFragment = null;

    public MyFragmentManagerPageAdatper(FragmentManager fm) {
        super(fm);
        this.mTaskFragment = new MaintainTaskFragment();
        this.mInspectionFragment = new RoutineInspectionFragment();
        this.mMoreFragment = new MoreFragment();
    }

    @Override
    public Object instantiateItem(ViewGroup vg, int position) {
        return super.instantiateItem(vg, position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        System.out.println("position Destory" + position);
        super.destroyItem(container, position, object);
    }

    @Override
    public Fragment getItem(int position) {
        Fragment fragment = null;
        switch (position){
            case 0:
                fragment = mTaskFragment;
                break;
            case 1:
                fragment = mInspectionFragment;
                break;
            case 2:
                fragment = mMoreFragment;
        }

        return fragment;
    }

    @Override
    public int getCount() {
        return 3;
    }
}
